<?php
/**
 * 教职工模型
 * @author GL
 * @date 2018.8.23
 */

namespace App\Model\Crm;

use App\model\BaseModel;
use DB;

class WorkerModel extends BaseModel{

    const USER = 'user';
    const USER_INFO = 'user_info';
    const DEPARTMENT = 'department';

    //模糊查询分组id
    public static function getGroupId($where = [], $field = ['id'])
    {
        return DB::table(self::DEPARTMENT)
                ->where($where)
                ->select($field)
                ->get();
    }    public static function forgetUser() {
    session()->forget('user_id');
    session()->forget('user');
}

    //获取教职工列表
    public static function getWorkerList($where = [], $field = '*', $offset = '10')
    {
        return DB::table(self::USER_INFO .' as info')
                ->leftJoin(self::USER . ' as user', 'user.id', '=', 'info.user_id')
                ->where($where)
                ->select($field)
                ->orderBy('info.create_at','desc')
                ->paginate($offset);
    }
}